Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpOpenAPI-4.0: implement validation #29687

Merged
merged 8 commits into from
Sep 27, 2024

Conversation

Azquelt
Copy link
Member

@Azquelt Azquelt commented Sep 20, 2024

Fixes #28860

@LibbyBot
Copy link

The following files contain a string indicating discriminating content:

  • dev/io.openliberty.microprofile.openapi.4.0.internal_fat/fat/src/io/openliberty/microprofile/openapi40/fat/validation/validation4.yml

@Azquelt Azquelt force-pushed the mpopenapi-40-validation branch 2 times, most recently from 080a2fd to d240017 Compare September 20, 2024 12:56
So that they can be shared with MP OpenAPI 4.0

Also add a validation result matcher so we get better test failure
messages.
Once the app has been deployed, we expect the messages to have been
logged, so we don't need to wait for them. This has no effect if the
test passes, but makes it run much more quickly if the expected messages
are not emitted.
@Azquelt Azquelt force-pushed the mpopenapi-40-validation branch 2 times, most recently from 0b57e23 to ae9f366 Compare September 20, 2024 15:12
@Azquelt
Copy link
Member Author

Azquelt commented Sep 20, 2024

#libby

@Azquelt
Copy link
Member Author

Azquelt commented Sep 20, 2024

#build
#spawn.fullfat.buckets=com.ibm.ws.microprofile.openapi.1.1_fat_tck,com.ibm.ws.microprofile.openapi_fat,com.ibm.ws.microprofile.openapi_fat_tck,com.ibm.ws.openapi.ui_fat,io.openliberty.microprofile.openapi.2.0.internal_fat,io.openliberty.microprofile.openapi.2.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.1.internal_fat_tck,io.openliberty.microprofile.openapi.4.0.internal_fat,io.openliberty.microprofile.openapi.4.0.internal_fat_tck,io.openliberty.microprofile.openapi.ui.internal_fat

@LibbyBot
Copy link

Your personal pipeline request is at https://libh-proxy1.fyre.ibm.com/cognitive/pipelineAnalysis.html?uuid=15a75c78-d991-42a3-9ea1-23a141218539

Target locations of links might be accessible only to IBM employees.

@Azquelt
Copy link
Member Author

Azquelt commented Sep 20, 2024

The following files contain a string indicating discriminating content:

This should now be fixed.

@LibbyBot
Copy link

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_erroUHdgEe-ZBdXWdK7Miw

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

@LibbyBot
Copy link

The build Azquelt-29687-20240920-1602
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_erroUHdgEe-ZBdXWdK7Miw
completed and has errors or failures.

For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_erroUHdgEe-ZBdXWdK7Miw

@Azquelt
Copy link
Member Author

Azquelt commented Sep 22, 2024

Fixed OSGi services not present during unit testing.

#build
#spawn.fullfat.buckets=com.ibm.ws.microprofile.openapi.1.1_fat_tck,com.ibm.ws.microprofile.openapi_fat,com.ibm.ws.microprofile.openapi_fat_tck,com.ibm.ws.openapi.ui_fat,io.openliberty.microprofile.openapi.2.0.internal_fat,io.openliberty.microprofile.openapi.2.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.1.internal_fat_tck,io.openliberty.microprofile.openapi.4.0.internal_fat,io.openliberty.microprofile.openapi.4.0.internal_fat_tck,io.openliberty.microprofile.openapi.ui.internal_fat

@LibbyBot
Copy link

Your personal pipeline request is at https://libh-proxy1.fyre.ibm.com/cognitive/pipelineAnalysis.html?uuid=b76f7cb8-b4b8-4e5f-b414-607fa2d10600

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_KWRkwHkpEe-PXJdaQbhamQ

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

@Azquelt
Copy link
Member Author

Azquelt commented Sep 23, 2024

Personal build looks good
#libby

@LibbyBot
Copy link

The build Azquelt-29687-20240922-1533
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_KWRkwHkpEe-PXJdaQbhamQ
completed successfully!

Copy link

@helyarp helyarp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested a minor change

schemaPropertyEmptyArray=The \"{0}\" property of the Schema Object is an empty array
schemaPropertyNotUnique=The elements of the \"{0}\" property of the Schema Object are not unique
schemaInvalidType=The \"type\" property of the Schema Object must only contain values which are one of (\"null\", \"boolean\", \"object\", \"array\", \"number\", \"integer\", \"string\")
schemaCollectionElementWrongType=The \"{0}\" property of the Schema Object contains a value which is not of type \"{1}\"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "which" with "that" or add a comma before "which"

@@ -64,6 +64,8 @@ nullValueInMap=The map specifies an invalid value for the \"{0}\" key. A map sho

openAPIVersionInvalid=The OpenAPI Object must contain a valid OpenAPI specification version. The \"{0}\" value specified for the OpenAPI specification version is not valid
openAPITagIsNotUnique=The OpenAPI Object must contain unique tag names. The \"{0}\" tag name is not unique
#3.1
openAPIMissingRequiredFields=The OpenAPI Object must contain at least one of the \"paths\", \"components\" or \"webhooks\" properties
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenAPI Object must contain at least one of the "paths", "components", or "webhooks" properties

@@ -112,9 +115,21 @@ schemaMultipleOfNotGreaterThanZero=The Schema Object must have the \"multipleOf\
schemaPropertyLessThanZero=The \"{0}\" property of the Schema Object must be greater than or equal to zero
schemaTypeDoesNotMatchProperty=The \"{0}\" property is not appropriate for the Schema Object of \"{1}\" type

#3.1
schemaPropertyWrongType=The \"{0}\" property of the Schema Object must be of type \"{1}\"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "{0}" property of the Schema Object must be a "{1}" type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still ok if the {1} variable starts with a vowel?

The values used for {1} in the code at the moment are "string", "number", "integer", "array", "object", "boolean", and "schema"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided on The type of the "{0}" property of the Schema Object must be "{1}"

schemaPropertyWrongType=The \"{0}\" property of the Schema Object must be of type \"{1}\"
schemaPropertyEmptyArray=The \"{0}\" property of the Schema Object is an empty array
schemaPropertyNotUnique=The elements of the \"{0}\" property of the Schema Object are not unique
schemaInvalidType=The \"type\" property of the Schema Object must only contain values which are one of (\"null\", \"boolean\", \"object\", \"array\", \"number\", \"integer\", \"string\")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "type" property of the Schema Object must contain values that are one of ("null", "boolean", "object", "array", "number", "integer", or "string")

schemaPropertyEmptyArray=The \"{0}\" property of the Schema Object is an empty array
schemaPropertyNotUnique=The elements of the \"{0}\" property of the Schema Object are not unique
schemaInvalidType=The \"type\" property of the Schema Object must only contain values which are one of (\"null\", \"boolean\", \"object\", \"array\", \"number\", \"integer\", \"string\")
schemaCollectionElementWrongType=The \"{0}\" property of the Schema Object contains a value which is not of type \"{1}\"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "{0}" property of the Schema Object contains a value that is not a "{1}" type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{1} may start with a vowel here too (same question as the above comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided on The "{0}" property of the Schema Object contains a value whose type is not "{1}"

@Azquelt
Copy link
Member Author

Azquelt commented Sep 24, 2024

Message review changes made.

#libby
#build
#spawn.fullfat.buckets=com.ibm.ws.microprofile.openapi.1.1_fat_tck,com.ibm.ws.microprofile.openapi_fat,com.ibm.ws.microprofile.openapi_fat_tck,com.ibm.ws.openapi.ui_fat,io.openliberty.microprofile.openapi.2.0.internal_fat,io.openliberty.microprofile.openapi.2.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.1.internal_fat_tck,io.openliberty.microprofile.openapi.4.0.internal_fat,io.openliberty.microprofile.openapi.4.0.internal_fat_tck,io.openliberty.microprofile.openapi.ui.internal_fat

@LibbyBot
Copy link

Your personal pipeline request is at https://libh-proxy1.fyre.ibm.com/cognitive/pipelineAnalysis.html?uuid=9638a01a-167d-443e-8f36-da4b64a9f7e8

Target locations of links might be accessible only to IBM employees.

Copy link

@is273 is273 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LibbyBot
Copy link

@Azquelt
Copy link
Member Author

Azquelt commented Sep 24, 2024

Missed a message change so need to re-request the build

#build
#spawn.fullfat.buckets=com.ibm.ws.microprofile.openapi.1.1_fat_tck,com.ibm.ws.microprofile.openapi_fat,com.ibm.ws.microprofile.openapi_fat_tck,com.ibm.ws.openapi.ui_fat,io.openliberty.microprofile.openapi.2.0.internal_fat,io.openliberty.microprofile.openapi.2.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.0.internal_fat_tck,io.openliberty.microprofile.openapi.3.1.internal_fat_tck,io.openliberty.microprofile.openapi.4.0.internal_fat,io.openliberty.microprofile.openapi.4.0.internal_fat_tck,io.openliberty.microprofile.openapi.ui.internal_fat

@LibbyBot
Copy link

Your personal pipeline request is at https://libh-proxy1.fyre.ibm.com/cognitive/pipelineAnalysis.html?uuid=04dbecd8-f26b-4e88-8a22-08b4df7be45e

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_85VRoHqgEe-PXJdaQbhamQ

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_4QaeYHqjEe-PXJdaQbhamQ

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

@Azquelt
Copy link
Member Author

Azquelt commented Sep 25, 2024

Personal build looks good

@LibbyBot
Copy link

The build Azquelt-29687-20240924-1921
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_85VRoHqgEe-PXJdaQbhamQ
completed successfully!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header date needs updating

@LibbyBot
Copy link

The build Azquelt-29687-20240924-1942
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_4QaeYHqjEe-PXJdaQbhamQ
completed successfully!

OpenAPI 3.1 is fairly similar to 3.0, so we re-use a lot of the same
validation logic.

As well as adding the new rules, we needed to:
- refactor reference validation, as references need to be validated
  differently
- Change how we select which validator to use so that its based on the
  OpenAPI version specified in the document rather than on which version
  of the feature is running (ensuring mpOpenAPI-4.0 can still validate
  OpenAPI v3.0 documents if the user has requested that)
- Make the 3.0 Schema validation code work with the mpOpenAPI-4.0 data
  model which has breaking API changes. The 3.0 validation needs to work
  with all versions of the model.
We were testing for each of the problem messages we expect, but we
weren't testing for the top message which says "The following errors
were found:"
Copy the existing OpenAPI v3.0 validation FAT tests and adjust them for
the new validation rules in v3.1 and run them against OpenAPI v3.1
documents.
@Azquelt
Copy link
Member Author

Azquelt commented Sep 26, 2024

Squashed the message reviews and updated the copyright headers.

#libby
#build

@LibbyBot
Copy link

Your personal pipeline request is at https://libh-proxy1.fyre.ibm.com/cognitive/pipelineAnalysis.html?uuid=a8a6ff16-6dac-44fb-924f-db293b95e6b9

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_kjdLQHwGEe-PXJdaQbhamQ

Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Code analysis and actions

DO NOT DELETE THIS COMMENT.
  • 38 product code files were changed.

  • Please describe in a separate comment how you tested your changes.

  • 29 FAT files were changed, added, or removed.

  • Check that the build did not break the affected FAT suite(s).

  • 38 unit test files were changed.

  • Check that the build did not break the affected unit test suite(s).

  • 1 messages files were changed and need an L2 review.

  • @OpenLiberty/message-reviewer Please review.

  • dev/io.openliberty.microprofile.openapi.internal.common/resources/io/openliberty/microprofile/openapi/internal/resources/validation/ValidationMessages.nlsprops

  • 1 NLS files were changed and need an ID review.

  • @OpenLiberty/message-reviewer Please review.

  • dev/io.openliberty.microprofile.openapi.internal.common/resources/io/openliberty/microprofile/openapi/internal/resources/validation/ValidationMessages.nlsprops

@LibbyBot
Copy link

@LibbyBot
Copy link

The build Azquelt-29687-20240926-0704
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_kjdLQHwGEe-PXJdaQbhamQ
completed and has errors or failures.

For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_kjdLQHwGEe-PXJdaQbhamQ

@Azquelt
Copy link
Member Author

Azquelt commented Sep 27, 2024

Errors in the build do not appear to related to this change.

@Azquelt Azquelt merged commit 8fb1a3f into OpenLiberty:integration Sep 27, 2024
2 of 3 checks passed
@Azquelt Azquelt deleted the mpopenapi-40-validation branch September 27, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement OpenAPI document validation on MP OpenAPI 4.0
5 participants